
import BasicController from './../BasicController'
import ErrorHandlerCode from './../../util/ErrorHandlerCode'
import UserModel from '../../model/user/UserModel'

class UserController extends BasicController{
    constructor(){
        super();
    }

    findUser(req, res, next){
        UserModel.findUser(req.body.id).then((data) => {
            this.RequestSuccessMsg(res, data);
        }).catch((err) => {
            res.json(ErrorHandlerCode.INNERSERVICERROR);
            throw err;
        })
    }
    findAllUser(req, res, next){
        UserModel.findAllUser().then((data) => {
            this.RequestSuccessMsg(res, data);
        })
    }
    userLogin(req, res){
        UserModel.userLogin(req.body).then((data) => {
            super.RequestSuccessMsg(res, data);
        }).catch((err) => {
            res.json(ErrorHandlerCode.INNERSERVICERROR);
            throw err;
        })
    }
    insertUser(req, res, next){
        UserModel.insertUser(req.body).then((data) => {
            this.RequestSuccessMsg(res, data);
        }).catch((err) => {
            res.json(ErrorHandlerCode.INNERSERVICERROR);
            throw err;
        });

    }
}

module.exports = new UserController();